Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.

Add opt-in versioned row publication mode - #186

Closed
pathscale wants to merge 2 commits into
fix/unique-read-revalidationfrom
feat/versioned-row-publication
Closed

Add opt-in versioned row publication mode#186
pathscale wants to merge 2 commits into
fix/unique-read-revalidationfrom
feat/versioned-row-publication

Conversation

@pathscale

@pathscale pathscale commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an opt-in versioned-row-publication mode for generated reads that overlap row mutation
  • publish immutable Arc<Row> versions while retaining archived pages as the persistence/mutation image
  • stage inserts as ghosted, publish only after index installation, and hide deleted versions
  • add a read-side grace period so delete/vacuum cannot reuse a physical link captured by an in-flight generated read
  • make primary/unique point reads retry a replacement-link swing and revalidate point/range predicates
  • serialize internal archived-page access in this mode; the default low-latency path is unchanged
  • use a feature-only lock-protected hash registry keyed by normalized physical offsets for publication metadata

This draft is stacked on #185 because it includes the unique point-read predicate revalidation from that PR.

Contract

With the feature enabled, generated reads return a complete old or new owned row version and never deserialize concurrently-mutated archived bytes. Insert ghosts and deleted rows are not returned, and retired links/pages are not reused until pre-existing generated readers drain.

This is not MVCC or a snapshot-isolation implementation. Range scans may include or omit rows changed during the scan. The guarantee excludes callers that bypass generated table methods and directly mutate low-level Data pages. Point-read retry may starve under perpetual replacement churn.

The protocol and scope are documented in docs/versioned-row-publication.md.

Validation

  • cargo test --all-targets: 115 unit tests and 326 active integration tests passed (5 ignored)
  • cargo test --all-targets --features versioned-row-publication: 119 unit tests and 328 active integration tests passed (5 ignored)
  • the concurrent unique-read/reinsert regression passed in five additional repeated runs
  • cargo clippy --all-targets -- -D warnings
  • cargo clippy --all-targets --features versioned-row-publication -- -D warnings
  • cargo fmt --all -- --check

Feature-only deterministic tests cover incomplete multi-field page mutation, ghost visibility, retired-version lifetime, physical-link ABA prevention, and integer/float range predicate revalidation.

Performance

Five alternating Criterion runs per mode on Darwin arm64, 20 samples/run, 0.2 s warmup, and 0.5 s measurement. The one-row range result uses seven alternating runs, 25 samples/run, 0.3 s warmup, and 0.7 s measurement after a shorter run showed excess variance.

Operation master feature off feature on
primary point read 54.803 ns 55.040 ns (+0.43%) 61.058 ns (+11.41%)
unique point read 55.415 ns 55.983 ns (+1.02%) 66.339 ns (+19.71%)
one-row unique range 321.490 ns 321.497 ns (+0.00%) 337.296 ns (+4.92%)
unique-index insert 930.020 ns 926.014 ns (-0.43%) 1.009 us (+8.44%)
unique-index update 1.826 us 1.819 us (-0.37%) 1.973 us (+8.06%)

Replacing the ordered publication index with the offset-keyed registry reduced the feature-on primary read from 96.811 ns to 61.058 ns and the feature-on unique read from 92.974 ns to 66.339 ns. Seven direct paired old/new runs also measured the optimized unique-index update 2.09% faster than the prior PR implementation. Read-only scaling and 2/4/8-writer contention checks showed no regression from the registry change.

The remaining feature-on cost is still material for latency-sensitive deployments. The feature remains off by default; feature-off point/read/write differences are at or below 1.02% in the final set.

Before merge

  • quantify live-row and retirement-queue memory overhead on representative schemas
  • model-check the grace-period/replacement protocol and add longer adversarial stress runs
  • decide whether point-read retry needs a documented bound
  • measure mixed read/write scaling on representative production hardware
  • reconcile this design with the global-barrier fallback in feat: gate synchronized page access #183 and the epoch-vacuum work in fix: replace vacuum delay with epoch grace period #184

@pathscale

Copy link
Copy Markdown
Owner Author

Superseded by #187, which consolidated and merged the backend-selection and publication hardening work after the combined review and validation rounds.

@pathscale pathscale closed this Aug 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant